<#if invalid?? && invalid>
<div class="alert alert-danger" role="alert">
	<strong>错误！</strong>
	无效的资金信息！
</div>
<#else>
<form class="bid-payout-form" action="${request.contextPath}/bid-money/edit" method="post">
	<input type="hidden" name="bid.id" value="${bidId}" />
	<input type="hidden" name="id" value="${data.id}" />
	<input type="hidden" name="payOut" value="${data.payOut?string('true','false')}" />
	<input type="hidden" name="gaveBack" value="${(data.gaveBack?string('true','false'))!''}" />
	<input type="hidden" name="backTime" value="${(data.backTime?string('yyyy-MM-dd'))!''}" />
	<input type="hidden" name="inAccount" value="${data.inAccount?string('true','false')}" />
	<input type="hidden" name="invoice" value="${data.invoice?string('true','false')}" />
	<div class="row">
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">
							<span class="not-null-star">*</span>
							资金名目
						</div>
					</div>
					<input type="text" class="form-control not-empty" name="name" value="${data.name}" readonly="readonly" />
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">
							<span class="not-null-star">*</span>
							支出金额
						</div>
					</div>
					<input type="text" class="form-control not-empty number" name="total" value="${data.total}" placeholder="请输入支出金额">
					<div class="input-group-addon">元</div>
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">
							<span class="not-null-star">*</span>
							支出日期
						</div>
					</div>
					<input type="text" class="form-control not-empty datetimepicker" data-format="yyyy-MM-dd" data-foot="false" data-time="${data.time}" name="time" placeholder="请选择日期" readonly="readonly">
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">收款单位/人</div>
					</div>
					<input type="text" class="form-control" name="source" value="${data.source}" placeholder="最多50个汉字">
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">备注</div>
					</div>
					<textarea rows="5" class="form-control" name="remark" value="${data.remark}" placeholder="最多500个汉字"></textarea>
				</div>
			</div>
		</div>
	</div>
	<hr>
	<div class="row">
		<div class="col-md-12 text-right">
			<div class="btn btn-primary btn-sm btn-submit">确定</div>
			&nbsp;
			<div class="btn btn-default btn-sm" onclick="$.suredy.closeModal();">关闭</div>
		</div>
	</div>
</form>
<script type="text/javascript">
	$(function() {
		// 初始化日期控件
		$.suredy.datetimepicker.init();

		$('form.bid-payout-form .btn-submit').on('click', function() {
			var form = $('form.bid-payout-form');

			// 校验表单
			if (!$.suredy.formChecker(form)) {
				return false;
			}

			var $this = $(this);

			if ($this.hasClass('disabled'))
				return false;

			$this.addClass('disabled');

			form.ajaxSubmit({
				dataType : "json",
				success : function(data, textStatus, jqXHR) {
					if (!data || !data.success) {
						alert(data.msg || '修改资金信息失败!');
						$this.removeClass('disabled');
						return false;
					}

					$.suredy.refreshContent('${bidId}', [ 'div.bid-payout' ]);

					$.suredy.closeModal();
				},
				error : function(jqXHR, textStatus, errorThrown) {
					alert('修改资金信息失败!\n' + errorThrown);
					$this.removeClass('disabled');
					return false;
				}
			});
		});
	});
</script>
</#if>
